package com.chen.authserver.resp;

import com.chen.authserver.constant.RespCode;
import lombok.Data;

@Data
public class RespMode<E> {

    private String code;

    private String msg;

    private E data;

    static public class Builder<E> {

        String code;
        String msg;
        E data;

        public Builder code(String code) {
            this.code = code;
            return this;
        }

        public Builder msg(String msg) {
            this.msg = msg;
            return this;
        }

        public Builder success() {
            return success(null);
        }

        public Builder success(E e) {
            this.code = RespCode.SUCCESS;
            this.msg = "success";
            this.data = e;
            return this;
        }

        public RespMode<E> build() {
            RespMode<E> respMode = new RespMode<>();
            respMode.setCode(this.code);
            respMode.setMsg(this.msg);
            respMode.setData(this.data);
            return respMode;
        }
    }
}
